package com.asyf.demo.demo.el;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author yjz
 * @Date 2023/1/29 17:24
 */
@Data
//@Builder//使用@Builder注解时同时会使用@AllArgsConstructor和@NoArgsConstructor
//@NoArgsConstructor
//@AllArgsConstructor
public class User {

    private int id;

    private String name;

    public User(int id, String name) {
        this.id = id;
        this.name = name;
    }

    List<Role> roleList;

    private String roleListStr;

    public String getRoleListStr() {
        return roleList.stream().map(o -> {
            return String.valueOf(o.getId());
        }).collect(Collectors.joining(","));
    }
}
